<template>
	<page-meta :page-style="$theme.pageStyle">
		<!-- #ifndef H5 -->
		<navigation-bar :front-color="$theme.navColor" :background-color="$theme.navBgColor" />
		<!-- #endif -->
	</page-meta>
	<view class="coupon-buy">
		<view class="coupon-card box-border bg-white flex items-center justify-between" v-for="(item, index) in formData.num2" :key="index" @click="codes">
			<view class="ml-4">
				<view class="font-medium text-4xl mb-7">{{ formData.title }}</view>
				<view>有效期至{{ formData.time }}</view>
			</view>
			<u-image class="mr-4" src="../../static/images/user/codeimg.png" width="90" height="90"></u-image>
		</view>
	</view>
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { geCouponMsg } from '@/api/user';

let yid = '';

const formData = ref<any>({
	num2:0
});

const getData = async (id) => {
	formData.value = await geCouponMsg({ id });
};

const codes = async () => {
	uni.navigateTo({
		url: '/pages/coupon_use/coupon_code?id=' + yid
	});
};

onLoad((options: any) => {
	yid=options.id;
});

onShow(async () => {
	getData(yid)
});

</script>

<style lang="scss">
.coupon-buy {
	height: 100%;

	.coupon-card {
		margin: 30rpx 20rpx;
		height: 200rpx;
	}
}
</style>
